home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club (Business) 1997 July / Software of the Month Club - Business (Volume 239) (July 1997).iso / pc / code / shared.dxr / 04482_data Logic.ls < prev    next >
Encoding:
Text File  |  1996-02-21  |  10.1 KB  |  353 lines

  1. global gNextEnvLetter, gNextDIRFile, gSoundChannels, gMIDIPlayTRUE, gInitalized, noteObjs, windowsMIDIXObj, xNAVXOBJ, xCURXOBJ, gCPU, gfileSep, gRootPath, gHDpath, gXobjs, gXOBJPath, gCDpath, gCDName, cNullCast, sCURSORSPRITE, prefsPath, startPath, miscXObjectPath, utilXObjectPath, miscXobj, myUtil, savedFilesPath, XObjectPath, extension, fileioXObjectPath, IOerrors, gStates, gCodePath, gKeyRef, gScreenState, gUnvObjects, gOBJECTS, gHotRects, gTempHotRects, gHaveNavs, gTempDialogText, gCurKeyList, gLastKeyList, gdirty, gdirtyGame, gQuitAfter, gQTcharState, cNUllCharmovie, sQTCharSprite
  2.  
  3. on massagegStatesForSave
  4.   set dynObjList to getaProp(gStates, #Dynamic)
  5.   set objtempList to [:]
  6.   set AlltempList to [:]
  7.   repeat with thisObjRef in dynObjList
  8.     set objtempList to [:]
  9.     set thisDynamicList to getaProp(getaProp(gOBJECTS, thisObjRef), #Dynamic)
  10.     if voidp(getaProp(getaProp(gOBJECTS, thisObjRef), #Dynamic)) then
  11.       setaProp(getaProp(gOBJECTS, thisObjRef), #Dynamic, [])
  12.     end if
  13.     if voidp(thisDynamicList) then
  14.       next repeat
  15.     end if
  16.     if count(thisDynamicList) = 0 then
  17.     end if
  18.     repeat with thisProp in thisDynamicList
  19.       set thisValue to getaProp(getaProp(gOBJECTS, thisObjRef), thisProp)
  20.       setaProp(objtempList, thisProp, thisValue)
  21.     end repeat
  22.     setaProp(AlltempList, thisObjRef, objtempList)
  23.   end repeat
  24.   setaProp(gStates, #dynamicData, AlltempList)
  25. end
  26.  
  27. on massagegStatesOnOpen
  28.   set Templist to getaProp(gStates, #dynamicData)
  29.   set howmanyObjs to count(Templist)
  30.   repeat with thisRefNum = 1 to howmanyObjs
  31.     set thisObjRef to getPropAt(Templist, thisRefNum)
  32.     set tempObj to getaProp(Templist, thisObjRef)
  33.     set tempDynamicList to []
  34.     set howmanyProps to count(tempObj)
  35.     repeat with thisPropNum = 1 to howmanyProps
  36.       set thisProp to getPropAt(tempObj, thisPropNum)
  37.       set thisValue to getaProp(tempObj, getPropAt(tempObj, thisPropNum))
  38.       if not voidp(getaProp(gOBJECTS, thisObjRef)) then
  39.         setaProp(getaProp(gOBJECTS, thisObjRef), thisProp, thisValue)
  40.       end if
  41.       add(tempDynamicList, thisProp)
  42.     end repeat
  43.     if not voidp(getaProp(gOBJECTS, thisObjRef)) then
  44.       setaProp(getaProp(gOBJECTS, thisObjRef), #Dynamic, tempDynamicList)
  45.       next repeat
  46.     end if
  47.     alert("This object does not exist" && thisObjRef && "-old data.")
  48.   end repeat
  49. end
  50.  
  51. on clearScreen
  52.   set Templist to []
  53.   repeat with thisPos in gScreenState
  54.     add(Templist, thisPos)
  55.   end repeat
  56.   Delobjects(Templist)
  57. end
  58.  
  59. on newGame
  60.   set gLastCursor to getaProp(gCursorList, #NullCursor)
  61.   set the loc of sprite sCURSORSPRITE to point(-2000, -2000)
  62.   startTheTimer(1, "NewGameTimer")
  63.   JumpToKey(#A00)
  64. end
  65.  
  66. on NewGameTimer
  67.   InitgObjects()
  68.   InittheTimer()
  69.   setaProp(gStates, #EnviroLetter, "A")
  70.   JumpToKey(#A03)
  71. end
  72.  
  73. on DoOpenGame
  74.   if gdirty <> 1 then
  75.     beep()
  76.     exit
  77.   end if
  78.   set gdirty to 0
  79.   makeDynamic(#SaveOBj, #Aquired, 0)
  80.   CloseOpenUNVDialog()
  81.   startTheTimer(1, "OpenGameTimer")
  82.   stopSound(#ALL)
  83.   stopSound(2)
  84.   set gSoundChannels to [:]
  85.   JumpToKey(#trans)
  86.   makeDynamic(#SaveOBj, #Aquired, 1)
  87. end
  88.  
  89. on OpenGameTimer
  90.   InitgObjects()
  91.   set JumpRef to OpenGameDataLoad()
  92.   InittheTimer()
  93.   setaProp(gStates, #EnviroLetter, char 1 of the movieName)
  94.   if JumpRef <> #BAD then
  95.     JumpToKey(JumpRef)
  96.     ADDUnvOBJECTS()
  97.   else
  98.     setaProp(gStates, #EnviroLetter, "A")
  99.     NewGameTimer()
  100.   end if
  101. end
  102.  
  103. on OpenGameDataLoad
  104.   if loadGameData() then
  105.     set NextKeyRef to getaProp(gStates, #curKey)
  106.     if voidp(NextKeyRef) then
  107.       set NextKeyRef to #BAD
  108.       displayChaosError(#severe, "The Data File is Corrupted" & RETURN & "See openGameDataLoad")
  109.     end if
  110.   else
  111.     set NextKeyRef to #BAD
  112.     displayChaosError(#severe, "The Data File has been Altered" & RETURN & "See openGameDataLoad")
  113.   end if
  114.   return NextKeyRef
  115. end
  116.  
  117. on SuppendCurrentKF
  118.   set aTime to the timer
  119.   set the timer to -(the maxinteger)
  120.   setSoundState(#pause)
  121.   set gQTcharState to [#loc: the loc of sprite sQTCharSprite, #movieTime: the movieTime of sprite sQTCharSprite, #movieRate: the movieRate of sprite sQTCharSprite, #fileName: the fileName of cast cNUllCharmovie, #sound: the sound of cast cNUllCharmovie, #loop: the loop of cast cNUllCharmovie, #pausedAtStart: the pausedAtStart of cast cNUllCharmovie, #timer: aTime, #gSoundChannels: gSoundChannels]
  122.   set gSoundChannels to [:]
  123.   set the movieRate of sprite sQTCharSprite to 0
  124.   set the sound of cast cNUllCharmovie to 1
  125.   set the loop of cast cNUllCharmovie to 0
  126.   set the pausedAtStart of cast cNUllCharmovie to 1
  127.   set the loc of sprite sQTCharSprite to point(-2000, -2000)
  128.   updateStage()
  129.   set C to sQTCharSprite - 1
  130.   set Animators to []
  131.   repeat with X = 2 to C
  132.     set ObjRef to getaProp(gScreenState, X)
  133.     if not voidp(ObjRef) then
  134.       set Anim to getaProp(getaProp(gOBJECTS, ObjRef), #Animator)
  135.       if not voidp(Anim) then
  136.         set CurState to the pbPauseState of Anim
  137.         set the pbPauseState of Anim to 1
  138.         add(Animators, [#Anim: Anim, #State: CurState])
  139.       end if
  140.     end if
  141.   end repeat
  142.   setaProp(gQTcharState, #Animators, Animators)
  143.   set gHaveNavs to #false
  144.   DELUnvOBJECTS()
  145.   set gTempHotRects to gHotRects
  146.   set gHotRects to [:]
  147.   sort(gHotRects)
  148. end
  149.  
  150. on ReinstateCurrentKF FileJump
  151.   if FileJump <> #true then
  152.     set gHotRects to gTempHotRects
  153.     sort(gHotRects)
  154.     set the fileName of cast cNUllCharmovie to getaProp(gQTcharState, #fileName)
  155.     set the sound of cast cNUllCharmovie to getaProp(gQTcharState, #sound)
  156.     set the pausedAtStart of cast cNUllCharmovie to getaProp(gQTcharState, #pausedAtStart)
  157.     set the loop of cast cNUllCharmovie to getaProp(gQTcharState, #loop)
  158.     set the loc of sprite sQTCharSprite to getaProp(gQTcharState, #loc)
  159.     set the movieTime of sprite sQTCharSprite to getaProp(gQTcharState, #movieTime)
  160.     set the movieRate of sprite sQTCharSprite to getaProp(gQTcharState, #movieRate)
  161.     set Animators to getaProp(gQTcharState, #Animators)
  162.     repeat with Anim in Animators
  163.       set the pbPauseState of getaProp(Anim, #Anim) to getaProp(Anim, #State)
  164.     end repeat
  165.     ADDUnvOBJECTS()
  166.     set gSoundChannels to getaProp(gQTcharState, #gSoundChannels)
  167.     setSoundVolumes()
  168.     setSoundState(#play)
  169.   else
  170.     if FileJump = #true then
  171.       set the fileName of cast cNUllCharmovie to string(gCDName & "DATA" & gfileSep & "QTDummy.MOV")
  172.       set gSoundChannels to [:]
  173.       sort(gSoundChannels)
  174.       setSoundVolumes()
  175.     end if
  176.   end if
  177.   set gHaveNavs to #true
  178.   set the timer to getaProp(gQTcharState, #timer)
  179. end
  180.  
  181. on doNothing
  182.   pass()
  183. end
  184.  
  185. on OpenUNVDialog
  186.   SuppendCurrentKF()
  187.   loadNames()
  188.   saveTempText()
  189.   unselectList()
  190.   ADDObjects([#OpenDialogBox])
  191.   updateStage()
  192. end
  193.  
  194. on CloseOpenUNVDialog
  195.   Delobjects([#OpenDialogBox])
  196.   ReinstateCurrentKF()
  197.   deleteProp(gStates, #dynamicData)
  198.   unselectList()
  199.   when keyDown then nothing
  200.   updateStage()
  201. end
  202.  
  203. on SaveUNVDialog
  204.   SuppendCurrentKF()
  205.   DELUnvOBJECTS()
  206.   loadNames()
  207.   saveTempText()
  208.   ADDObjects([#SaveDialogBox])
  209.   updateStage()
  210.   when keyDown then processInputFieldChar "SaveName"
  211. end
  212.  
  213. on CloseSaveUNVDialog
  214.   Delobjects([#SaveDialogBox])
  215.   ReinstateCurrentKF()
  216.   deleteProp(gStates, #dynamicData)
  217.   unselectList()
  218.   when keyDown then nothing
  219.   updateStage()
  220. end
  221.  
  222. on OpenNewGameDialog
  223.   ADDObjects([#NewGameDialog])
  224.   updateStage()
  225. end
  226.  
  227. on closeNewGameDialog
  228.   Delobjects([#NewGameDialog])
  229.   cursor([the number of cast "NullCursor", the number of cast "NullCursor.mask"])
  230. end
  231.  
  232. on OpenGameNow
  233.   set gHotRects to [:]
  234.   sort(gHotRects)
  235.   OpenUNVDialog()
  236. end
  237.  
  238. on StartNewGame
  239.   closeNewGameDialog()
  240.   if the movieName contains "intro" then
  241.     cursor([the number of cast "NullCursor", the number of cast "NullCursor.mask"])
  242.     go("Intro QT")
  243.   else
  244.     newGame()
  245.   end if
  246. end
  247.  
  248. on DoSaveCancel
  249.   CloseSaveUNVDialog()
  250.   put gTempDialogText into field getaProp(getaProp(getaProp(gOBJECTS, #SaveNameText), #cast), #text)
  251.   set gTempDialogText to EMPTY
  252.   if getaProp(getaProp(gOBJECTS, #QuitYetDialog), #gQuitAfter) = 1 then
  253.     halt()
  254.   end if
  255. end
  256.  
  257. on DoOpenCancel
  258.   CloseOpenUNVDialog()
  259.   put gTempDialogText into field getaProp(getaProp(getaProp(gOBJECTS, #SaveNameText), #cast), #text)
  260.   set gTempDialogText to EMPTY
  261.   set gdirty to 0
  262.   if the movieName starts "Intro" then
  263.     closeNewGameDialog()
  264.     go("Intro QT")
  265.   end if
  266. end
  267.  
  268. on doQuitCancel
  269.   CloseQuitDialog()
  270. end
  271.  
  272. on CloseQuitDialog
  273.   Delobjects([#QuitYetDialog])
  274.   ReinstateCurrentKF()
  275.   updateStage()
  276.   ADDUnvOBJECTS()
  277.   unselectList()
  278.   when keyDown then nothing
  279. end
  280.  
  281. on OpenQuitDialog
  282.   SuppendCurrentKF()
  283.   DELUnvOBJECTS()
  284.   ADDObjects([#QuitYetDialog])
  285.   updateStage()
  286. end
  287.  
  288. on SavethenQuit
  289.   DoUnvSaveandQuit()
  290. end
  291.  
  292. on DoUnvSaveandQuit
  293.   setaProp(getaProp(gOBJECTS, #QuitYetDialog), #gQuitAfter, 1)
  294.   if (getaProp(gStates, #gCurrentGameName) <> #virgin) and (not gdirtyGame = 1) then
  295.     SaveGameData()
  296.   else
  297.     SaveUNVDialog()
  298.   end if
  299. end
  300.  
  301. on saveTempText
  302.   if getaProp(gStates, #gCurrentGameName) = #virgin then
  303.     put EMPTY into field getaProp(getaProp(getaProp(gOBJECTS, #SaveNameText), #cast), #text)
  304.     set gTempDialogText to field getaProp(getaProp(getaProp(gOBJECTS, #SaveNameText), #cast), #text)
  305.   else
  306.     set gTempDialogText to field getaProp(getaProp(getaProp(gOBJECTS, #SaveNameText), #cast), #text)
  307.   end if
  308. end
  309.  
  310. on processInputFieldChar fieldName
  311.   set theKey to the key
  312.   if theKey = numToChar(8) then
  313.     deleteInputFieldChar(fieldName, theKey)
  314.     exit
  315.   end if
  316.   if (charToNum(theKey) >= 32) and (charToNum(theKey) <= 122) then
  317.     addInputFieldChar(fieldName, theKey)
  318.   end if
  319. end
  320.  
  321. on addInputFieldChar fieldName, theKey
  322.   if (length(field fieldName) = 1) and (field fieldName = " ") then
  323.     put theKey into field fieldName
  324.   else
  325.     if length(field fieldName) < 19 then
  326.       put field fieldName & theKey into field fieldName
  327.     else
  328.       nothing()
  329.     end if
  330.   end if
  331. end
  332.  
  333. on deleteInputFieldChar fieldName, theKey
  334.   if length(field fieldName) > 0 then
  335.     put chars(field fieldName, 1, length(field fieldName) - 1) into field fieldName
  336.   else
  337.     nothing()
  338.   end if
  339. end
  340.  
  341. on addSavedGameName
  342. end
  343.  
  344. on loadNames
  345.   set ThisList to savedGameNames()
  346.   set howMany to count(ThisList)
  347.   repeat with thisOne = 1 to howMany
  348.     put getAt(ThisList, thisOne) into line thisOne of temp
  349.   end repeat
  350.   put RETURN after temp
  351.   put temp into field getaProp(getaProp(getaProp(gOBJECTS, #pickListText), #cast), #text)
  352. end
  353.